package com.walkud.rxjava.utils;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * 日志打印观察者(订阅者)
 *
 * @param <T>
 */
public class PrintLogSubscriber<T> implements Observer<T> {

    public PrintLogSubscriber() {
    }

    public static <T> PrintLogSubscriber<T> create() {
        return new PrintLogSubscriber<>();
    }

    @Override
    public void onSubscribe(Disposable d) {
        System.out.println("onSubscribe()");
    }

    @Override
    public void onNext(T t) {
        System.out.println("onNext():" + t);
    }

    @Override
    public void onError(Throwable e) {
        System.out.println("onError():" + e.getMessage());
    }

    @Override
    public void onComplete() {
        System.out.println("onComplete()");
    }
}
